﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using WalkingTec.Mvvm.Core;
using WalkingTec.Mvvm.Core.Extensions;
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;
using WTM.Model;


namespace WTM.ViewModel.BaseData.Work_RyVMs
{
    public partial class Work_RyListVM : BasePagedListVM<Work_Ry_View, Work_RySearcher>
    {

        protected override IEnumerable<IGridColumn<Work_Ry_View>> InitGridHeader()
        {
            return new List<GridColumn<Work_Ry_View>>{
                this.MakeGridHeader(x => x.work_view),
                this.MakeGridHeader(x => x.Xm_view),
                this.MakeGridHeader(x => x.Fpzt),
                this.MakeGridHeader(x => x.Remark),
                this.MakeGridHeaderAction(width: 200)
            };
        }

        public override IOrderedQueryable<Work_Ry_View> GetSearchQuery()
        {
            var query = DC.Set<Work_Ry>()
                .CheckEqual(Searcher.WorksId, x=>x.WorksId)
                .CheckEqual(Searcher.RyId, x=>x.RyId)
                .CheckEqual(Searcher.Fpzt, x=>x.Fpzt)
                .CheckContain(Searcher.Remark, x=>x.Remark)
                .Select(x => new Work_Ry_View
                {
				    ID = x.ID,
                    work_view = x.Works.work,
                    Xm_view = x.Ry.Xm,
                    Fpzt = x.Fpzt,
                    Remark = x.Remark,
                })
                .OrderBy(x => x.ID);
            return query;
        }

    }

    public class Work_Ry_View : Work_Ry{
        [Display(Name = "工作名称")]
        public String work_view { get; set; }
        [Display(Name = "姓名")]
        public String Xm_view { get; set; }

    }
}
